from tortoise import fields
from .base import BaseModel, TimestampMixin

class OrdersList(BaseModel, TimestampMixin):
    water_no = fields.CharField(max_length=255,null=True, description="流水号")
    user_id = fields.IntField(default=0, description="用户id")
    type = fields.IntField(default=1, description="订单类型1点单2商城")
    price = fields.DecimalField(max_digits=10, decimal_places=2, description="订单总金额")
    amount_price = fields.DecimalField(max_digits=10, decimal_places=2, description="实际支付")
    sale_price = fields.DecimalField(max_digits=10, decimal_places=2, description="优惠金额")
    sale_roles = fields.JSONField( null=True, description="优惠规则")
    status = fields.IntField(default=0, description="0待支付,1已支付,2已取消,3已退款")
    pay_time = fields.DatetimeField(max_length=255, null=True, description="付款时间")
    exp_time = fields.DatetimeField(max_length=255, null=True, description="支付超时时间")
    is_express = fields.IntField(default=0, description="0待发货,2部分发货,1已发货")
    express = fields.JSONField( null=True, description="物流状态")
    express_price = fields.DecimalField(max_digits=10, decimal_places=2, description="运费")
    receive_name = fields.CharField(max_length=255, null=True, description="收件人")
    receive_phone = fields.CharField(max_length=255, null=True, description="收件电话")
    receive_address = fields.CharField(max_length=255, null=True, description="收件地址")
    goods = fields.JSONField(null=True, description="商品详情")
    remark = fields.CharField(max_length=255, null=True, description="订单备注")
    address_id = fields.IntField(default=0,null=True, description="门店id")
    is_give = fields.IntField(default=0, null=True, description="是否赠送0否1是")
    is_deposit = fields.IntField(default=0, null=True, description="是否储值金购买")
    deposit_price = fields.DecimalField(max_digits=10, decimal_places=2, description="储值金支付金额")
    coupons = fields.JSONField(null=True, description="优惠券ids")
    coupons_price = fields.DecimalField(max_digits=10, decimal_places=2, description="优惠券支付金额")
    refund_time = fields.DatetimeField(max_length=255, null=True, description="退款时间")
    is_draw = fields.IntField(default=0, null=True, description="是否可以抽奖0不可1可以")
    draw_id = fields.IntField(default=0, null=True, description="抽奖记录ID")
    add_uid = fields.IntField(default=0, null=True, description="后端录入人id")
    order_rate = fields.IntField(default=5, null=True, description="评价星级")
    order_evaluations = fields.CharField(max_length=300, null=True, description="订单评价(限制字数90)")
    is_review = fields.IntField(default=0, null=True, description="是否评价")

    class Meta:
        table = "orders_list"


class OrdersWater(BaseModel, TimestampMixin):
    order_id = fields.IntField(default=0, description="订单id")
    amount = fields.DecimalField(max_digits=10, decimal_places=2, description="微信支付金额")
    out_trade_no = fields.CharField(max_length=255,null=True, description="商户订单号")
    transaction_id = fields.CharField(max_length=255,null=True, description="微信支付流水号")
    success_time = fields.DatetimeField(max_length=255, null=True, description="支付成功时间")

    class Meta:
        table = "orders_water"

class OrdersGoods(BaseModel, TimestampMixin):
    user_id = fields.IntField(default=0, description="用户id")
    order_id = fields.IntField(default=0, description="订单id")
    goods_id = fields.IntField(default=0, description="商品id")
    sku_id = fields.IntField(default=0, description="sku_id")
    price = fields.DecimalField(max_digits=10, decimal_places=2, description="商品单价")
    sku_name = fields.CharField(max_length=255, null=True, description="规格名称")
    sale_price = fields.DecimalField(max_digits=10, decimal_places=2, description="优惠金额")
    sale_roles = fields.JSONField(null=True, description="优惠规则")
    num = fields.IntField(default=1, description="商品数量")
    status = fields.IntField(default=0, description="0待支付,1已支付,2已取消,3已退款")
    is_express = fields.IntField(default=0, description="0待发货,1已发货")
    express_company = fields.CharField(max_length=255, null=True, description="物流公司")
    express_no = fields.CharField(max_length=255, null=True, description="物流单号")
    remark = fields.JSONField(null=True, description="下单备注")
    attr = fields.JSONField(null=True, description="点单加料")
    class Meta:
        table = "orders_goods"

class OrdersReceive(BaseModel, TimestampMixin):
    user_id = fields.IntField(default=0, description="用户id")
    receive_name = fields.CharField(max_length=255, null=True, description="收件人")
    receive_phone = fields.CharField(max_length=255, null=True, description="收件电话")
    receive_city = fields.CharField(max_length=255, null=True, description="收件城市")
    receive_address = fields.CharField(max_length=255, null=True, description="收件地址")
    is_default = fields.BooleanField(default=True, description="是否默认")
    class Meta:
        table = "orders_receive"

class OrdersCar(BaseModel, TimestampMixin):
    user_id = fields.IntField(default=0, description="用户id")
    goods_id = fields.IntField(default=0, description="商品id")
    price = fields.DecimalField(max_digits=10, decimal_places=2, description="商品单价")
    sku_id = fields.IntField(default=0, description="ske的id")
    sku_name = fields.CharField(max_length=255, null=True, description="规格名称")
    sale_price = fields.DecimalField(max_digits=10, decimal_places=2, description="优惠金额")
    num = fields.IntField(default=1, description="商品数量")

    class Meta:
        table = "orders_car"

class OrdersExpress(BaseModel, TimestampMixin):
    order_id = fields.IntField(default=0, description="OrdersList的id")
    order_goods_id = fields.JSONField(null=True, description="OrdersGoods的id")
    express_company = fields.CharField(max_length=255, null=True, description="物流公司")
    express_no = fields.CharField(max_length=255, null=True, description="物流单号")

    class Meta:
        table = "orders_express"